package utils

import (
	"blog_server/utils/errmsg"
	"github.com/gin-gonic/gin"
	"net/http"
)

func Response(c *gin.Context, code int, data gin.H, msg string) {
	c.JSON(http.StatusOK, gin.H{"code": code, "data": data, "msg": msg})
}

func Success(c *gin.Context, data gin.H) {
	Response(c, errmsg.SUCCESS, data, errmsg.GetErrorMsg(errmsg.SUCCESS))
}

func Fail(c *gin.Context, data gin.H) {
	Response(c, errmsg.ERROR, data, errmsg.GetErrorMsg(errmsg.ERROR))
}
